#{extends 'main.html' /}
#{set title:'Template Matcher' /}

<div class="row">
<div class="col-md-6">
#{form @controllers.TemplateTester.index()}
<div class="form-group">
    <label for="datagramText">Datagram Text</label>
    <textarea class="form-control" rows="15" id="datagramText" name="datagramText">${datagramText}</textarea>
    <small>The control characters \x01 \x02 \x03 can be replcaed by ☐.</small>
</div>
<p><input type="submit" class="btn btn-primary btn-lg" value="Match" />
</p>

#{/form}


#{if templates}

<h3>Matched Templates</h3>

#{TA014_table items:templates, datagramText:datagramText/}

#{/if}

#{if guessedTemplates}
<h3>Guessing Matched Templates</h3>

<table class="table table-bordered table-stripped">
    <thead>
    <th>ID</th>
    <th>SPLIT_TEMPLATE_NAME</th>
    <th>AVIATION</th>
    <th>DEPARTMENT</th>
    <th>SIGNER</th>
    <th>MARKER</th>
    <th>MARKER_POS</th>
    <th>SMI</th>
    <th>TYPE</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    </thead>
    #{list items:guessedTemplates, as:'item' }
        <tr>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getId()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getSplit_template_name()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getAviation()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getDepartment()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getSigner()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getMarker()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getMarker_pos()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getSmi()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}">${item.getType()}</td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}"><a href="@{controllers.SplitTemplate.edit(item.getId())}">详细</a></td>
            <td class="${item.rank>0 ? 'highlighted' : 'normal'}"><a href="@{controllers.TemplateTester.doSplit(item.getId(), datagramText)}" target="_blank">TEST</a></td>
        </tr>
    #{/list}
</table>
#{/if}
</div>
</div>
